<template>
  <div class="verify_container">
    <el-steps
      :active="1"
      class="steps"
    >
      <!-- 第一步 -->
      <el-step
        title="身份验证"
        icon="iconfont icon-yanzheng"
      ></el-step>

      <!-- 第二步 -->
      <el-step
        title="修改密码"
        icon="iconfont icon-xiugaimima"
      ></el-step>

      <!-- 第三步 -->
      <el-step
        title="成功"
        icon="el-icon-success"
      ></el-step>
    </el-steps>

    <div class="verify_box">
      <el-form
        :model="verifyForm"
        :rules="rules"
        ref="verifyForm"
        class="demo-verifyForm"
      >
        <p>身份验证</p>
        <el-divider></el-divider>

        <!-- 手机号 -->
        <el-form-item prop="phone">
          <el-input
            v-model="verifyForm.phone"
            autocomplete="off"
            placeholder="手机号码"
          ></el-input>
        </el-form-item>

        <!-- 短信验证码 -->
        <el-form-item prop="authCode">
          <el-input
            class="input_authCode"
            v-model="verifyForm.imgauthCode"
            autocomplete="off"
            placeholder="输入验证码"
          ></el-input>
        </el-form-item>

        <!-- 短信验证码 -->
        <el-form-item prop="authCode">
          <el-input
            class="input_authCode"
            v-model="verifyForm.authCode"
            autocomplete="off"
            placeholder="输入6位短信验证码"
          ></el-input>

          <!-- 发送验证码按钮 -->
          <el-button
            class="btn_authCode"
            type="primary"
          >发送验证码</el-button>
        </el-form-item>

        <!-- 注册按钮 -->
        <el-form-item>
          <el-button
            style="width: 370px"
            type="primary"
            @click="modifyPass"
          >下一步</el-button>
        </el-form-item>

        <div class="span_div">
          <span>已有账号？</span>
          <span
            class="span_text"
            @click="login"
          >马上登录</span>
        </div>
      </el-form>
    </div>

  </div>

</template>

<script>
export default {
  data() {
    //手机号验证
    var validatePhone = (rule, value, callback) => {
      const patter = new RegExp("^1[0-9]{10}$"); //简单验证11位手机号

      if (!patter.test(value)) {
        return callback(new Error("请输入正确格式的手机号！"));
      } else {
        callback(); //必须有此项回调，否则验证会一直不通过
      }
    };
    return {
      verifyForm: {
        phone: "", //手机号
        imgauthCode: "", //图片验证码
        authCode: "", //短信验证码
      },
      rules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        phone: [{ validator: validatePhone, trigger: "blur" }],
      },
    };
  },
  components: {},
  methods:{
    //登录
    login(){
        this.$router.push({ path: "/login" }); //页面路由跳转
    },
    //修改密码
    modifyPass(){
      this.$router.push({ path: "/Modifypass" }); //页面路由跳转
    }
  }
};
</script>

<style lang='less' scoped>
.verify_container {
  min-width: 1024px;
  min-height: 640px;
  height: 100%;
}
.steps {
  padding-top: 50px;
  width: 576px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.verify_box {
  display: block;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  width: 400px;
  height: 371px;
  background-color: #f9f8f8;
  border-radius: 5px; // 圆角
  position: absolute;
  top: 130px;
  left: 0;
  right: 0;
  margin: auto;
  //   top: 40%;
  //   left: 50%;
  //   transform: translate(-50%, -50%); // 根据自己位置 以自己为长度位移

  .demo-verifyForm {
    position: absolute;
    width: 100%;
    padding: 10px 20px;
    box-sizing: border-box; // 设置边框

    p {
      font-size: 14px;
      font-weight: bold;
    }
    .el-divider {
      margin-top: 10px;
    }

    .input_authCode {
      width: 210px;
      padding-right: 5px;
    }

    .btn_authCode {
      width: 145px;
    }
    .span_div {
      display: flex; // 弹性布局
      justify-content: center; // 居中对齐
      font-size: 15px;
      margin-bottom: 25px;
    }
    .span_text {
        cursor: pointer;
        color: #409eff;
      }
  }
}
</style>
